home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / ada_tutr.zip / DAT2TXT.ADA < prev    next >
Text File  |  1994-08-22  |  2KB  |  48 lines

  1. -- DAT2TXT.ADA   Ver. 3.00   22-AUG-1994   Copyright 1988-1994 John J. Herro
  2. -- Software Innovations Technology
  3. -- 1083 Mandarin Drive NE, Palm Bay, FL  32905-4706   (407)951-0233
  4. --
  5. -- Run this program on a PC before installing ADA-TUTR on another computer.
  6. -- It translates ADA_TUTR.DAT to TUTOR.TXT, a text file that can be easily
  7. -- transferred to other computers.  Then compile and run TXT2DAT.ADA on the
  8. -- other machine to create ADA_TUTR.DAT from TUTOR.TXT.
  9. --
  10. with Direct_IO, Text_IO;
  11. procedure DAT2TXT is
  12.    subtype Block_Subtype is String(1 .. 64);
  13.    package Random_IO is new Direct_IO(Block_Subtype);
  14.    Data_File  : Random_IO.File_Type;                         -- The input file.
  15.    Text_File  : Text_IO.File_Type;                          -- The output file.
  16.    Block      : Block_Subtype;             -- A block of 64 bytes being copied.
  17.    OK         : Boolean := True;     -- True when both files open successfully.
  18.    Legal_Note : constant String := " Copyright 1988-94 John J. Herro ";
  19.                        -- Legal_Note isn't used by the program, but it causes
  20.                        -- most compilers to place this string in the .EXE file.
  21. begin
  22.    begin
  23.       Random_IO.Open(Data_File, Random_IO.In_File, Name => "ADA_TUTR.DAT");
  24.    exception
  25.       when Random_IO.Name_Error =>
  26.          Text_IO.Put_Line(
  27.               "I'm sorry.  The file ADA_TUTR.DAT seems to be missing.");
  28.          OK := False;
  29.    end;
  30.    begin
  31.       Text_IO.Create(Text_File, Name => "TUTOR.TXT");
  32.    exception
  33.       when others =>
  34.          Text_IO.Put_Line("I'm sorry.  I can't seem to create TUTOR.TXT.");
  35.          Text_IO.Put_Line("Perhaps that file already exists?");
  36.          OK := False;
  37.    end;
  38.    if OK then
  39.       while not Random_IO.End_Of_File(Data_File) loop
  40.          Random_IO.Read(Data_File, Item => Block);
  41.          Text_IO.Put_Line(File => Text_File, Item => Block);
  42.       end loop;
  43.       Random_IO.Close(Data_File);
  44.       Text_IO.Close(Text_File);
  45.       Text_IO.Put_Line("TUTOR.TXT created.");
  46.    end if;
  47. end DAT2TXT;
  48.